<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
if($_RQ['op']=='edit'){
	$item=pdo_get('jy_kexie_project_user',array('id'=>$this->user_id,'uniacid'=>$_SESSION['uniacid']));
	unset($item['password']);
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('name'=>'name','title'=>'姓名','type'=>'string'),
					array('name'=>'username','title'=>'用户名称','type'=>'string'),
					array('name'=>'password','title'=>'密码','type'=>'password'),
					//array('name'=>'area_idtitle','title'=>'所属区域','type'=>'copy'),
					//array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
				)
			),
		)
	);
	$return['status']=array('0'=>'关闭','1'=>'开启');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['name']){
		exi('请填写姓名','error');
	}
	$data=array_fields(array('name','username','password','status'),$postdata);
	if($data['password']){
		$data['password']=base64_encode($data['password']);
	}
	$id=intval($postdata['id']);	
	if($id){
		pdo_update('jy_kexie_project_user',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	exi('操作成功！','','list');
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_kexie_project_user',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
if($_RQ['op']=='set'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要编辑的专家！','error');
	}
	$post=get_postdata();
	if(isset($post['status'])){
		pdo_update('jy_kexie_project_user',array('status'=>intval($post['status'])),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	exi('操作成功！');
}